package com.ruoyi.project.cms.sale.service.impl;

import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.cms.client.domain.CmsClient;
import com.ruoyi.project.cms.client.mapper.CmsClientMapper;
import com.ruoyi.project.cms.sale.domian.Sale;
import com.ruoyi.project.cms.sale.mapper.SaleMapper;
import com.ruoyi.project.cms.sale.service.ISaleService;
import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.user.domain.User;
import com.ruoyi.project.system.user.mapper.UserMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类名:SaleServiceImpl
 * 描述:销售怒业务实现层
 * 作者:邓怀广
 * 时间:2020-05-19
 */
@Service("sale")
public class SaleServiceImpl implements ISaleService {
    private static final Logger log = LoggerFactory.getLogger(SaleServiceImpl.class);

    @Autowired
    private SaleMapper saleMapper;

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private CmsClientMapper clientMapper;

    @Override
    public List<Sale> selectSaleList(Sale sale) {
        return saleMapper.selectList(sale);
    }

    @Override
    public List<User> selectUserList() {
        return userMapper.selectList();
    }

    @Override
    public int add(Sale sale) {
        return saleMapper.insertSelective(sale);
    }

    @Override
    public Sale selectSaleById(Long sId) {
        return saleMapper.selectSaleById(sId);
    }

    @Override
    public int updateSale(Sale sale) {
        return saleMapper.updateByPrimaryKeySelective(sale);
    }

    @Override
    public int deleteSaleByIds(String ids) {
        Long[] sIds = Convert.toLongArray(ids);
        return saleMapper.deleteSaleByIds(sIds);
    }

    @Override
    public List<CmsClient> selectClientList() {
        return clientMapper.selectClientList();
    }
}
